#include "UserProfileHeader.h"

UserProfileHeader::UserProfileHeader(QWidget *parent)
    : QWidget{parent}
{
    QHBoxLayout *layout = new QHBoxLayout(this);

    // 设置圆形头像
    avatar = new AvatarLabel(this);
    avatar->setFixedSize(120, 120);
    layout->addWidget(avatar);

    avatar->setPixmap(QPixmap(":/test/resoures/test/avatar1.png"));

    // 用户信息
    QVBoxLayout *infoLayout = new QVBoxLayout();

    // 第一行：用户名和编辑按钮
    QHBoxLayout *topInfoLayout = new QHBoxLayout();
    username = new QLabel("脸滚键盘1201", this);
    username->setFont(QFont("Arial", 24, QFont::Bold)); // 设置字体大小为24，加粗显示
    safeButton = new QPushButton("🔒 解除封禁", this);

    // 设置按钮样式
    QString buttonStyle = R"(
        QPushButton {
            background-color: #f0f0f0;
            border: 1px solid #ccc;
            border-radius: 15px;
            font-size: 16px;
            font-weight: bold;
            color: #333;
        }
        QPushButton:hover {
            background-color: #e0e0e0;
        }
        QPushButton:pressed {
            background-color: #d0d0d0;
        }
    )";
    safeButton->setFixedSize(110, 30);
    safeButton->setStyleSheet(buttonStyle);

    topInfoLayout->addWidget(username);
    topInfoLayout->addStretch();
    topInfoLayout->addWidget(safeButton);
    infoLayout->addLayout(topInfoLayout);

    // 申诉理由
    signature = new QLabel("申诉理由：申诉理由演示", this);
    infoLayout->addWidget(signature);

    layout->addLayout(infoLayout);
    setLayout(layout);

    connect(safeButton, &QPushButton::clicked, this, &UserProfileHeader::onSafeButtonClicked);
}

void UserProfileHeader::onSafeButtonClicked()
{
    QMessageBox::warning(this, "提示", "确认解除账户封禁？");
}
